<?php

$dynlname = $_POST['hidden_dynlname'];
//echo 'fieldname-->'.$dynlname;
$fieldlist = spliti(";",$_POST['hidden_fieldlist']);
//echo 'fieldlist-->';
//print_r($fieldlist);

$action = $_POST['action'];
echo $action;
switch ($action) {
	case 'Save':
		$pageback = '<script type=""text/javascript"">window.location = "/dynlist/index.php?xcode=data!'.$dynlname.'!save_record!';
		$pageback .= define_fields_2_update($dynlname,$fieldlist);
		break;
		
	case 'Cancel':
		$pageback = '<script type=""text/javascript"">window.location = "/dynlist/index.php?xcode=data!'.$dynlname.'!cancel';
		break;

	case 'New Record':
		$pageback = '<script type=""text/javascript"">window.location = "/dynlist/index.php?xcode=data!'.$dynlname.'!new_record';
		break;
}

//print_r($pageback);
echo $pageback.'";</script>';

	//echo 'teste---->'.$_POST['dbtabname'];}

function define_fields_2_update($dynlname,$fieldlist)
{
	$i = 0;
	foreach ($fieldlist as $fieldname)
	{
		$fields_2_update .= $fieldname.'~'.$_POST[$fieldname];
		if ($i <= count($fieldlist))
		{	
			$fields_2_update .= ';';
		}
		$i++;
	}
	return $fields_2_update;
}

?>


